<script type="text/javascript">
$(function(){
	array=[];//清空数组
	$.get("makeCard/getCardInfo",function(data){
		var content="<option value='' selected>请选择</option>";
		$(data).each(function(n,item){
				for(i=0;i<item.cdProDefinitions.length;i++){
				content+="<option value="+item.cdProDefinitions[i].cardpCode+">"
				+item.cdProDefinitions[i].cardpName+"</option>"
			};
			$("#cardCodeByTask").html(content);
		});	
	},"json");
	$.post("tellerManage/getpaperAndBranch",function(json){
		 var contentb="<option value='' >请选择</option>";
		 $(json).each(function(n,item){
			for(i=0;i<item.branchs.length;i++){
				contentb+="<option value="+item.branchs[i].orgName+">"
				+item.branchs[i].orgName+"</option>"
			};
			$("#netDotByMakeCardBatchExport").html(contentb);
		 });
		
	 },"json")
	$.ajax({
		type: 'POST',
		url:"makeCardTaskExport/getTaskInfo",
		dataType:"json",
		cache: false,
		success: getTaskInfo,//回调函数
		error: DWZ.ajaxError
	});	
});

//打开dialog---------------------------------------
function openDialogTasked(a){
	//alert($(a).text());
	var parm=$(a).text()
	var options={"width":"500","height":"400","parm":parm};
	$.pdialog.open("makeCardTaskExport/infosByTasked/","infos", "详细信息",options);
	
}
//验证复选框---------------------------------------------------------------------
function validateChechBox2(){
	var len=array.length;
	if(len==0){
		alertMsg.warn("您未选择数据！")
		 return false;
	}
	if(len>=2){
		for(var i=0;i<array.length;i++){
			var currentCardP=array[i].split("#")[2];
			var nextCardP=array[i+1].split("#")[2];
			var currentCardT=array[i].split("#")[3];
			var nextCardT=array[i+1].split("#")[3];
			if(currentCardP!=nextCardP){
				alertMsg.warn("您选择的卡产品不同");
				return false;
			}
			if(currentCardT!=nextCardT){
				alertMsg.warn("您选择的卡物理类型不同");
				return false;
			}
		} 
	}
/* 	 var length =$("input[name='tasked']:checked").length;
	 if(length >= 2){
		 for(var i=0;i<length;i++){
			var currentCardP=$("input[name='tasked']:checked:eq("+i+")").parent().parent().find("td:eq(3)").text();
			var nextCardP=$("input[name='tasked']:checked:eq("+(i+1)+")").parent().parent().find("td:eq(3)").text();
			var currentCardT=$("input[name='tasked']:checked:eq("+i+")").parent().parent().find("td:eq(4)").text();
			var nextCardT=$("input[name='tasked']:checked:eq("+(i+1)+")").parent().parent().find("td:eq(4)").text();
			if(nextCardP==""||nextCardT==""){
				//alert("都已经比对完成了")
				return  true;
			}
			if(currentCardP!=nextCardP){
				alertMsg.warn("您选择的卡产品不同");
				return false;
			}
			if(currentCardT!=nextCardT){
				alertMsg.warn("您选择的卡物理类型不同");
				return false;
			}
		 }
	 } */
	return true;
}
//导出任务提交-------------------------------------------------
function comitFormByExportTask(form){
	$form=$(form);
	 if (!$form.valid()) {
		return false;
	}
	 $.ajax({
			url:$form.attr("action"),
			 dataType:'json',
			 type:"post",
		 	 traditional:true,
		 	 data:{
		 		 "array":array
		 	 },
		 	success:refreshTask
		})
	return false;	
}
//导出任务刷新页面-----------------------------------------------
function refreshTask(json){
	$(json).each(function(n,item){
		if(item.statusCode=="200"){
			alertMsg.correct("任务导出成功!");
			array=[];//清空数组
			$.ajax({
				type: 'POST',
				url:"makeCardTaskExport/getTaskInfo",
				data:$("#pagerForm").serialize(),
				dataType:"json",
				cache: false,
				success: getTaskInfo,//回调函数
				error: DWZ.ajaxError
			});
		}	
		var paths = item.paths
		for(var i in paths){
			window.location.href = paths[i]
		}
		
		
	});
	
	
};
</script>

<div class="pageHeader ">
	<form id="pagerForm" method="post" action="makeCardTaskExport/getTaskInfo" class="pageForm required-validate" onsubmit="return validateCallback(this,getTaskInfo);">
		<input type="hidden" name="pageNum" value="" /> 
		<input type="hidden" name="numPerPage" value="" />
		<!-- <input type="hidden" name="pageCount" value="" /> -->
		<div class="searchBar">
			<!-- <table class="searchContent">
			<tr>
				<td style="text-align:left"><label>卡产品：</label></td>
				<td style="text-align:left"><select id="cardCodeByTask" name="cardPCode" class="">
			
				</select></td>
			
				<td style="text-align:left"><label>任务名称：</label></td>
				<td style="text-align:left"><input  name="taskName"  class="" type="text" size="30"  alt="请输入……"/></td>
			</tr>
			<p>
				<label>制卡单位：</label>
				<select id="companyByTask" name="cardPCode" class="">
			
				</select>
			</P>
			<tr>
				<td style="text-align:left"><label>网点：</label></td>
				<td style="text-align:left"><input  name="netDot" class="" type="text" size="30"  alt="请输入……"/></td>
			
				<td><label>任务生成日期(起)：</label>
				<td><input  name="startDate" class="date" type="text" size="30"  />
			</tr>
			<tr>
				<td><label>任务生成日期(止)：</label></td>
				<td><input  name="endDate" class="date" type="text" size="30" /></td>
			</tr>
			</table> -->
			<div class="row" style="padding: 0 10px;">
		<div class="col-md-6 col-sm-12" >
			<p ><label>卡产品：</label>
			<select id="cardCodeByTask" name="cardPCode" class=""></select>
			</p>			
		</div>
		<div class="col-md-6 col-sm-12" >
			<p >
			<label>任务名称：</label>
			<input  name="taskName"  class="validApplyNo" type="text" size="30"/>
			</p>
		</div>
		</div>
		<div class="row" style="padding: 0 10px;">
		<div class="col-md-6 col-sm-12" >
			<p >
			<label>申请网点：</label>
			<select id="netDotByMakeCardBatchExport" name="netDot" ></select>
			</p>
		</div>
		<div class="col-md-6 col-sm-12" >
			<p >
			<label>任务生成日期(起)：</label><input  name="startDate" class="date validDateFrom" type="text" size="30"  />
			</p>
		</div>
		</div>
		<div class="row" style="padding: 0 10px;">
		<div class="col-md-6 col-sm-12" >
			<p ><label>任务生成日期(止)：</label><input  name="endDate" class="date validDateTo" type="text" size="30" />
			</p>			
		</div>
		
		</div>
	
		<div class="subBar">
			<ul> 
				<li>
				<div class="buttonActive" ><div class="buttonContent" ><button type="submit" onclick="initCurrentPage()">查询</button></div></div>
				</li>
			</ul>
		</div>
		</div>
	</form>	
</div>

<form method="post" action="makeCardTaskExport/exportTask" class="pageForm required-validate" onsubmit="return comitFormByExportTask(this);">
	<div class="pageContent">
	<div id="ByMakeCardBatchExp">
		<table class="table" width="100%" layoutH="298">
			<thead>
				<tr align="center">
					<th width="2%"><input type="checkbox" onclick="checkAllSave(this)" name="" group="tasked" class="checkboxCtrl"></th>
					<th width="23%" >任务编号</th>
					<th width="10%">任务名称</th>
					<th width="10%" >卡产品</th>
					<th width="10%" >卡物理类型</th>
					<th width="5%" >数量</th>
					<th width="15%" >申请网点</th>
					<th width="10%">制卡单位</th>
					<th width="10%">任务生成日期</th>
					<th width="5%">备注(是否加急)</th>
				</tr>
			</thead>
			<tbody id="tbodyBytasked">
			</tbody>
		</table>
		</div>
	<!-- <div class="panelBar">
		<div class="pages">
			<span>显示</span>
			<select id="numPerPageByTsaked" name="numPerPage" onchange="paging(this,$('#getTaskInfo'),getTaskInfo)">
				<option value="20">20</option>
				<option value="30">30</option>
				<option value="50">50</option>
				<option value="100">100</option>
			</select>
			<span id="totalCountByTasked" ></span>
		</div>
			<div id="paginationByTasked" class="pagination1"  ></div>
	</div> -->
	<div class="panelBar">
		<div class="pages">
			<span>显示</span>
			<select class="combox" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value},'tbodyBytasked',getTaskInfo)">
				<option value="20">20</option>
				<option value="50">50</option>
				<option value="100">100</option>
				<option value="200">200</option>
			</select>
			<span id="totalCountByTasked">条，共${totalCount}条</span>
		</div>

		<div callback='getTaskInfo' id="paginationByTasked" rel="tbodyBytasked" class="pagination" targetType="navTab" totalCount="200" numPerPage="5" pageNumShown="5" currentPage="1"></div>

	</div>
	<!-- <div class="pageFormContent"> -->
		 <div class="formBar">
			<ul> 
				<li>
					<div class="buttonActive" >
						<div class="buttonContent" ><button type="submit" onclick="return validateChechBox2();">导出</button></div>	
					</div>
				</li>
			</ul></div> 
			
		
	<!-- </div> -->
</div>
	</form>
	

